// 项目中所有请求
import ajax from "./ajax"
import mockAjax from "./mockAjax"

// home组件
// 请求三级菜单栏的数据
export const reqCategoryList = ()=> ajax({url: '/product/getBaseCategoryList',method:'get'})
// 请求轮播banner数据
export const reqBannerList = () => mockAjax({url:'/banner',method:'get'})
// 请求floor数据
export const reqFloorList = () => mockAjax({ url: '/floor', method: 'get' })

// search组件
// 请求搜索商品的数据
export const reqGoodsList = (searchParams) => ajax({ url: '/list', method: 'post', data: searchParams })

// detail组件
// 请求商品详情页数据
export const reqDetailInfo = (skuId) =>ajax({ url: `/item/${skuId}`, method: 'get' })

// addCartSuccess组件
// 添加商品
export const reqAddGoods = (skuId, skuNum) => ajax({ url:`/cart/addToCart/${ skuId }/${ skuNum }`,method:'post'})

// shopCart组件
// 获取购物车商品列表
export const reqShopCartList = () => ajax({ url:'/cart/cartList',method:'get'})

// 修改单个选中状态
export const reqChangeOneChecked = (skuId, isChecked) => ajax({ url:`/cart/checkCart/${skuId}/${isChecked}`,method:'get'})

// 批量选中和不选中
export const reqCheckedAll = (isChecked, skuIdList) => ajax({ url: `/cart/batchCheckCart/${isChecked}`, method: 'post', data: skuIdList })

// 删除单个商品
export const reqDeleteOne = (skuId) => ajax({ url:`/cart/deleteCart/${skuId}`,method:'delete'})

// 删除选中的商品
export const reqCheckedGood = (skuIdList) => ajax({ url: '/cart/batchDeleteCart', method: 'post', data: skuIdList })

// 登录注册组件
// 获取验证码
export const reqCode = (phone) => ajax({ url:`/user/passport/sendCode/${phone}`,method:'get'})

// 注册用户
export const reqRegisterUser = (paramsObj) => ajax({ url:'/user/passport/register',method:'post',data:paramsObj})

// 登录获取token
export const reqLogin = (paramsObj) => ajax({ url: '/user/passport/login', method: 'post', data: paramsObj })

// 根据token获取用户信息
export const reqUserInfo = () => ajax({ url:'/user/passport/auth/getUserInfo',method:'get'})

// 退出登录
export const reqLoginOut = () => ajax({ url:'/user/passport/logout',method:'get'})

// 结算组件
// 获取用户地址
export const reqUserAddress = () => ajax({ url:'/user/userAddress/auth/findUserAddressList',method:'get'})

// 获取订单商品信息
export const reqTradeInfo = () => ajax({ url:'/order/auth/trade',method:'get'})

// 提交订单获取订单号
export const reqSubmitOrder = (tradeNo,orderParams) => ajax({ url:`/order/auth/submitOrder?tradeNo=${tradeNo}`,method:'post',data:orderParams})

//获取订单支付信息
export const reqOrderPayInfo = (orderId) => ajax({ url:`/payment/weixin/createNative/${orderId}`,method:'get'})

// 查询用户是否支付成功
export const reqPayState = (orderId) => ajax({ url:`/payment/weixin/queryPayStatus/${orderId}`,method:'get'})

// 获取我的订单页面数据
export const reqMyOrderInfo = (page, limit) => ajax({ url:`/order/auth/${page}/${limit}`,method:'get'})